{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def select_question(question_list):\n",
    "    return random.choice(question_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def answer_question(question,answer):\n",
    "    if question == '打开灯光':\n",
    "        if answer == '1':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '通过急弯':\n",
    "        if answer == '2':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '通过拱桥':\n",
    "        if answer == '2':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '通过人行横道':\n",
    "        if answer == '2':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '通过没有交通信号灯控制的路口':\n",
    "        if answer == '2':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '同方向近距离跟车行驶':\n",
    "        if answer == '3':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '与机动车会车':\n",
    "        if answer == '3':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '通过交通信号灯控制的路口':\n",
    "        if answer == '3':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '在有路灯照明良好的道路上行驶':\n",
    "        if answer == '3':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')\n",
    "    elif question == '在照明不良的道路行驶':\n",
    "        if answer == '4':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')  \n",
    "    elif question == '在无照明的道路行驶':\n",
    "        if answer == '4':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误')  \n",
    "    elif question == '超越前方车辆':\n",
    "        if answer == '5':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误') \n",
    "    elif question == '路边临时停车':\n",
    "        if answer == '6':\n",
    "            print('回答正确')\n",
    "        else:\n",
    "            print('回答错误') \n",
    "    else:\n",
    "        print('异常情况')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def main():\n",
    "    while True:\n",
    "        question = select_question(question_list)\n",
    "        print(question)\n",
    "        answer = str(input('开大灯请输入 1\\n远近交替请输入 2\\n近光灯请输入 3\\n远光灯请输入 4\\n左转灯——>远近交替——>右转灯——>复位请输入 5\\n示宽灯 + 报警灯请输入 6\\n请输入数字：'))\n",
    "        answer_question(question,answer)\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "question_list = ['打开灯光','通过急弯','通过坡路','通过拱桥','通过人行横道','通过没有交通信号灯控制的路口',\\\n",
    "                '同方向近距离跟车行驶','与机动车会车','通过交通信号灯控制的路口','在有路灯照明良好的道路上行驶',\\\n",
    "                '在照明不良的道路行驶','在无照明的道路行驶','超越前方车辆','路边临时停车']\n",
    "\n",
    "main()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
